package com.ruoyi.order.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.order.mapper.StatisticGreenhouseMapper;
import com.ruoyi.order.domain.StatisticGreenhouse;
import com.ruoyi.order.service.IStatisticGreenhouseService;

/**
 * VIEWService业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-08
 */
@Service
public class StatisticGreenhouseServiceImpl implements IStatisticGreenhouseService 
{
    @Autowired
    private StatisticGreenhouseMapper statisticGreenhouseMapper;




    /**
     * 查询VIEW列表
     * 
     * @param statisticGreenhouse VIEW
     * @return VIEW
     */
    @Override
    public List<StatisticGreenhouse> selectStatisticGreenhouseList(StatisticGreenhouse statisticGreenhouse, SysUser user)
    {
        List<SysRole> roles = user.getRoles();
        for (SysRole role : roles) {
            if("片区总管".equals(role.getRoleName())||"棚长".equals(role.getRoleName())||"棚员".equals(role.getRoleName())){
                return statisticGreenhouseMapper.selectStatisticGreenhouseListWithoutPrices(user.getUserId());
            }
            if("总经理".equals(role.getRoleName())||"财务采购经理".equals(role.getRoleName())||"销售经理".equals(role.getRoleName())){
                return statisticGreenhouseMapper.selectStatisticGreenhouseList(statisticGreenhouse);
            }
        }

        return statisticGreenhouseMapper.selectStatisticGreenhouseListWithoutPrices(null);
    }


}
